package demo1;

public class Base {
    public Base(){
        System.out.println("Base()");
    }
    {
        System.out.println("实例代码块执行");
    }
    static {
        System.out.println("静态代码块执行");
    }

}

class Derived extends Base{
    {
        System.out.println("子类实例代码块执行");
    }
    static {
        System.out.println("子类静态代码块执行");
    }
    public Derived(){
        //super(); //在调用子类构造方法时，会隐式默认调用基类的无参构造方法：super()
        //super()必须是子类构造方法的第一条语句
        //并且在构造方法中只能出现一次
        System.out.println("Derived()");
    }
}

class Test{
    public static void main(String[] args) {
        Derived derived = new Derived();
        System.out.println("-----------------");
        Derived derived1 = new Derived();
    }
}